@echo Off
set config=%1
if "%config%" == "" (
   set config=Release
)

%windir%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe SlamCms.sln /t:Clean,Rebuild /p:Configuration="%config%" /m /nr:false /v:M /fl /flp:LogFile=msbuild.log;Verbosity=Normal

if not "%errorlevel%"=="0" goto failure

rd Build /s /q 

if not exist Build mkdir Build\

if not exist Build\SlamCms.Core mkdir Build\SlamCms.Core\
if not exist Build\SlamCms.Core\lib mkdir Build\SlamCms.Core\lib\
if not exist Build\SlamCms.Core\lib\net35 mkdir Build\SlamCms.Core\lib\net35\

if not exist Build\SlamCms.Mvc mkdir Build\SlamCms.Mvc\
if not exist Build\SlamCms.Mvc\lib mkdir Build\SlamCms.Mvc\lib\
if not exist Build\SlamCms.Mvc\lib\net4 mkdir Build\SlamCms.Mvc\lib\net4\

copy src\SlamCms.Core\bin\%config%\SlamCms.Core.dll Build\SlamCms.Core\lib\net35\
copy src\SlamCms.Core\bin\%config%\SlamCms.Core.pdb Build\SlamCms.Core\lib\net35\
REM copy src\SlamCms.Core\bin\%config%\SlamCms.Core.xml Build\SlamCms.Core\lib\net35\

copy src\SlamCms.Mvc\bin\%config%\SlamCms.Mvc.dll Build\SlamCms.Mvc\lib\net4\
copy src\SlamCms.Mvc\bin\%config%\SlamCms.Mvc.pdb Build\SlamCms.Mvc\lib\net4\
REM copy src\SlamCms.Mvc\bin\%config%\SlamCms.Mvc.xml Build\SlamCms.Mvc\lib\net4\

nuget.exe pack SlamCms.Core.nuspec -Symbols -BasePath Build\SlamCms.Core -Output Build
nuget.exe pack SlamCms.Mvc.nuspec -Symbols -BasePath Build\SlamCms.Mvc -Output Build

if not "%errorlevel%"=="0" goto failure

:success

REM success

rem exit 0

:failure

REM failure

rem exit -1